$(function(){
	$(".btn2").click(function(){
		window.location.href='addGoods.jsp';
	})
	/*表单提交*/
	/*var validator = $("#sampleT").validate({
        rules : {
            // 对应表单元素的name属性
<<<<<<< HEAD
=======
            "version" : {required:true,number:true},
>>>>>>> e512520135f25dd25a3d70aa043a5be87e7fefd6
            "serialnumber" : {required:true,number:true},
            "isSty" : {required:true},
            "structore" : {required:true},
            "priceHz" : {required:true,number:true},
            "priceDk" : {required:true,number:true},
            "priceSHz" : {required:true,number:true},
            "descript" : {required:true},
            "wash" : {required:true},
            "locationId" : {required:true},
            "structure" : {required:true},
            "spur" : {required:true},
            "timeFold" : {required:true},
            "sampleType" : {required:true},
            "optionalType" : {required:true},
            "clothList" : {required:true},
            "kinds" : {required:true},
            "color" : {required:true},
            "mainCloth" : {required:true},
            "setSize" : {required:true},
            "styleId" : {required:true},
            "breadthStatus" : {required:true},
            "series" : {required:true,number:true},
        },
        messages : {
        	"isSty":{required:'请选择图片款式'},
        	"serialnumber":{required:'请输入型号'},
        	"series":{required:'请输入系列号'},
        	"structore":{required:'请选择结构'},
<<<<<<< HEAD
            "serialnumber" : {required:'请输入型号'},
            "brand" : {required:'请输入品牌'},
=======
            "version" : {required:'请输入型号'},
>>>>>>> e512520135f25dd25a3d70aa043a5be87e7fefd6
            "priceHz" : {required:'请输入价格'},
            "priceDk" : {required:'请输入价格'},
            "priceSHz" : {required:'请输入价格'},
            "wash" : {required:'请输入洗涤说明'},
            "locationId" : {required:'请选择场景'},
            "structure" : {required:'请选择结构'},
            "spur" : {required:'请选择花距'},
            "timeFold" : {required:'请选择倍褶'},
            "sampleType" : {required:'请选择样品类型'},
            "optionalType" : {required:'请选择可选类型'},
            "clothList" : {required:'请选择材质'},
            "kinds" : {required:'请选择材质'},
            "color" : {required:'请选择颜色'},
            "mainCloth" : {required:'请选择材质'},
            "setSize" : {required:'请选择尺寸'},
            "breadthStatus" : {required:'请选择定宽/定高'},
            "styleId" : {required:'请选择风格'},
            "descript" : {required:'请输入描述'},
            "price" : {required:'请输入价格'},
        },
        errorElement : "span",
        errorPlacement: function(error, element) {
            error.appendTo(element.parent());
        }
     })*/
     /*提交商品信息*/
     var submitData = $("#sampleT").serialize();
	 data= decodeURIComponent(submitData,true);//防止中文乱码
     data = data.replace(/&/g, "','" );
     data = data.replace(/=/g, "':'" );
     data = "({'" +data + "'})" ;
     /*$("#buYiLianNext").click(function(){
    	 //console.log(validator.form());
    	 //console.log("222");
    	 $.ajax({
    		    type: "POST",
    		    url: $("#sampleT").attr("action"),
    		    success: function(data) {
    		    	console.log(data);
    	             //var dataT = JSON.parse(data);
    	             //console.log(validator.form());
    		    	if(validator.form()){
    		    		if(data.status == '0') {
	       	                 alert("保存成功");
	       	                 $("form")[0].reset();
	       	                 setTimeout(function(){
	       	                     //window.location.href = 'checkResult.html?sampleId='+dataT.data+'';
	       	                 },1000);
	       	             } else {
	       	                 alert("保存失败，请重试！");
	       	             }
    		    	}
    	             
    		    }
    	});*/
    	/* 
    	$.post(
    	$("form").serialize(),
    	function(dataT){
             //var dataT = JSON.parse(data);
             //console.log(validator.form());
             if(dataT.status == '0') {
                 alert("保存成功");
                 $("form")[0].reset();
                 setTimeout(function(){
                     //window.location.href = 'checkResult.html?sampleId='+dataT.data+'';
                 },1000);
             } else {
                 alert("保存失败，请重试！");
             }
         },'json')    
     }) */
     /*点击添加风格*/
     $(".toAdd").hide();
     $(".addBtn").click(function(){
     	$(".addButton input").show();
     	$(".toAdd").show();
     })
     $(".toAdd").click(function(){
     		var styleVal = $(".addButton input").val();
     		if(styleVal == ""){
     		    alert("请输入文字");
     		}else{
     			$.post('http://192.168.0.25:8080/bukeManage/shoppingmall/addStyle.do',{'styleContent':styleVal},function(data){
     				/*console.log(styleVal);
     			    console.log(data);*/
     				var inpEle = '<label class="checkbox-inline"><input type="checkbox" value="'+data+'">'+styleVal+'</label>';
     				//console.log(inpEle);
     				$("#fengge").append(inpEle);
     				$(".addButton input").val("");
     				$(".addButton input").hide();
     				$(".toAdd").hide();
     				$("#fengge .checkbox-inline").remove();
     				tianjiaStyle();
     			})
     		}		
     	})
     $(".toAdd1").hide();
     $(".addBtn1").click(function(){
     	$(".addButton1 input").show();
     	$(".toAdd1").show();
     	
     })
     $(".toAdd1").click(function(){
     		var styleVal1 = $(".addButton1 input").val();
     		if(styleVal1 == ""){
     			alert("请输入文字");
     		}else{
     			$.post('http://192.168.0.25:8080/bukeManage/shoppingmall/addLocation.do',{'locationContent':styleVal1},function(data){
     				//console.log(styleVal1);
     			    var inpEle = '<label class="checkbox-inline"><input type="checkbox" value="'+data+'">'+styleVal1+'</label>';
     				$("#changjing").append(inpEle);
     				$(".addButton1 input").val("");
     				$(".addButton1 input").hide();
     				$(".toAdd1").hide();
     				$("#changjing .checkbox-inline").remove();
     				tianjiaLocation();
     			})
     		}		
     	})
     /*上传商品型号查询重复*/
 	$("#serialnumber").blur(function(){
 		var numInp = $("#serialnumber").val();
 		$.post("http://192.168.0.25:8080/bukeManage/shoppingmall/select_serialnumber.do",{"serialnumber":numInp},function(numberData){
 			console.log(typeof(numberData));
 			var numberData = JSON.parse(numberData);
 			if(numberData == "1"){
 				alert("您输入的型号已存在，请重新输入");
 				$("#serialnumber").val("");	
 			}
 		})
 	})
     /*成品帘*/
 	$("#serialnumber1").blur(function(){
 		//console.log("222");
 		var numInp = $("#serialnumber1").val();
 		$.post("http://192.168.0.25:8080/bukeManage/shoppingmall/select_serialnumber.do",{"serialnumber":numInp},function(numberData){
 			//console.log(typeof(numberData));
 			var numberData = JSON.parse(numberData);
 			if(numberData == "1"){
 				alert("您输入的型号已存在，请重新输入");
 				$("#serialnumber1").val("");
 			}
 		})
 	})
})
	/*配件*/
	$("#serialnumber2").blur(function(){
		var numInp = $("#serialnumber2").val();
		console.log(numInp);
		$.post("http://192.168.0.25:8080/bukeManage/shoppingmall/select_serialnumber.do",{"serialnumber":numInp},function(numberData){
			//console.log(typeof(numberData));
			var numberData = JSON.parse(numberData);
			if(numberData == "1"){
				alert("您输入的型号已存在，请重新输入");
				$("#serialnumber2").val("");
			}
		})
	})
	
	